/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package commands;

import java.util.List;

/**
 *
 * @author ylopez
 */
public class dmonComandos {

    public static void printResoults(String flag, String[] resoults){
        System.out.println("Inicio ejecuci'on "+ flag +":");
        if (flag.equals("tuser")) {
            for (int i = 0; i < resoults.length; i += 2) {
                System.out.println(resoults[i] + " " + resoults[i+1]);
            }
        }

        if (flag.equals("nops")) {
            System.out.println(resoults[0]);
            System.out.println(resoults[1]);
        }
        System.out.println("Final ejecuci'on "+ flag +".");
    }

    public static String[] tuser(List users){
        Object[] usersArray = users.toArray();
        String[] resoult = new String[2*usersArray.length];
        String[] tmp;
        for (int i = 0; i < usersArray.length; i++) {
            tmp = (usersArray[i].toString()).split("  ");
            resoult[2*i] = tmp[0];
            resoult[2*i+1] = tmp[1];
        }
        return resoult;
    }

    public static String[] nops(int[] count){
        String sube = "No. operaciones sube: " + String.valueOf(count[1]);
        String baja = "No. operaciones baja: " + String.valueOf(count[2]);
        String[] resoult = new String[]{sube,baja};

        return resoult;
    }

    public static void dropUser(String[] user, List users){
        Object[] usersArray = users.toArray();
        String tmp;
        for (int i = 0; i < usersArray.length; i++) {
            tmp = usersArray[i].toString();
            if (tmp.equals(user[0]+ "  " + user[1])){
                users.remove(users.get(i));
            }
        }
    }

}
